# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=highlight
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.15
pkgrel=1
pkgdesc="Fast and flexible source code highlighter (CLI version) (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="http://www.andre-simon.de/doku/highlight/highlight.html"
msys2_repository_url="https://gitlab.com/saalen/highlight/"
msys2_references=(
  'archlinux: highlight'
)
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-boost"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=("http://www.andre-simon.de/zip/${_realname}-${pkgver}.tar.bz2"{,.asc}
        "001-fix-installation-prefix-and-destdir.patch"
        "002-fix-data-dir-stat.patch"
        "003-highlight-lspclient-workaround-symbol-conflict.patch")
sha256sums=('68b3f8178c5c9d4b0a03f6948635cef1c8d06244f6b438eebf3a190c588337e9'
            'SKIP'
            '13bfb4f326bd890c14c70c0fb30fc1d9ca7a0a8f0712f1c5e946bb59b942f3bb'
            'c371d1d2b98d364eedcfd7e2dfec1359bdcdeb73d7521331fa28c00623b4b9e2'
            '845e2a5968a0a9d9efd7c5ad1613523ea5f882a9f083d35ab6b64438f4bcf216')
validpgpkeys=('B8C55574187F49180EDC763750FE0279D805A7C7') # Andre Simon (Saalen) <as@andre-simon.de>

prepare() {
  cd "$srcdir/${_realname}-${pkgver}/"
  patch -p1 -i "${srcdir}"/001-fix-installation-prefix-and-destdir.patch
  patch -p1 -i "${srcdir}"/002-fix-data-dir-stat.patch
  patch -p1 -i "${srcdir}"/003-highlight-lspclient-workaround-symbol-conflict.patch
}

build() {
  cp -r "$srcdir/${_realname}-${pkgver}/" "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  make PREFIX=${MINGW_PREFIX} CXX_DIR=
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  DESTDIR="${pkgdir}" PREFIX=${MINGW_PREFIX} make install
}
